<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<!-- 开发环境版本，包含了有帮助的命令行警告 -->
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<title></title>
</head>
<body>
	<div id="app">
		<button @click="countAdd">点我</button>
		<!-- 第一步 给子组件绑定ref -->
		<comp ref="myRef"></comp>
	</div>

	<template id="tmp">
		<h1>{{count}}</h1>
	</template>
	
	<script type="text/javascript">
		let comp=Vue.extend({
			template: "#tmp",
			data(){
				return {
					count:1
				}
			},
			methods:{
				addCount(){
					this.count++
				}
			}
		})
		let app=new Vue({
			el:"#app",
			methods:{
				countAdd(){
					//第二步 在父组件使用this.$refs.ID就能获得
					this.$refs.myRef.count++
				}
			},
			components:{
				comp
			}
		})
	</script>
</body>
</html>